<% content_for :body_content_left do %>

  <% cart = @current_cart %>

  <%= form_tag(customer_signed_in? ? (defined?(OrdersController) ? delivery_address_path : "#") : "#" ) do %>

    <% if cart.line_items.present? %>
      <table>
        <th>Product</th>
        <th class="price">Unit Price</th>
        <th>Qty</th>
        <th>Modify Quantity / Delete</th>
        <th class="price">Full Price</th>

        <% cart.line_items.each do |cart_item| %>
          <tr>
            <td><%= product_or_variant_name(cart_item) %></td>
            <td><%= product_or_variant_price(cart_item) %></td>
            <td><%= cart_item.quantity %></td>
            <td><%= link_to image_tag("/images/plus.png", :size => "20x20"), variant_exists?(cart_item) ? increment_cart_path(cart_item.product, :quantity => 1, :variant => {:id => cart_item.variant}) : increment_cart_path(cart_item.product) %>
              <%= link_to image_tag("/images/minus.png", :size => "20x20"), variant_exists?(cart_item) ? increment_cart_path(cart_item.product, :quantity => -1, :variant => {:id => cart_item.variant}) : increment_cart_path(cart_item.product, :quantity => -1) unless cart_item.quantity == 1 %>
              <%= link_to "Delete", destroy_line_item_path(cart_item), :confirm => 'Are you sure?' %>
            </td>
            <td><%= cart_item_total(cart_item) %></td>
          </tr>
        <% end %>

        <tr>
          <td colspan="4">TOTAL</td>
          <td><%= rands(cart.grand_total) %></td>
        </tr>
      </table>

      <% if defined?(OrdersController) %>
        <div class="orderButton"><%= submit_tag 'Checkout', :id => customer_signed_in? ? "" : "checkout" %></div>
      <% end %>
    <% else %>
      <p>Your cart is currently empty.</p>
    <% end %>


  <% end %>

  <script type="text/javascript">
    if (typeof jQuery != 'undefined') {
      $(document).ready(function() {
        $('a.single').click(function(e) {
          e.preventDefault();
        });
      });
    }
  </script>

<% end %>

<%= render :partial => "/shared/content_page" %>
